<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>九宫格抽奖</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background-color: #f0f0f0;
        }
        .grid {
            display: grid;
            grid-template-columns: repeat(3, 100px);
            grid-gap: 10px;
            margin-bottom: 20px;
        }
        .cell {
            width: 100px;
            height: 100px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #ff7e5f, #feb47b);
            border-radius: 50%;
            font-size: 18px;
            cursor: pointer;
            color: white;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .active {
            background: linear-gradient(135deg, #00b894, #00d26a);
        }
        #control-panel {
            margin-top: 20px;
        }
        #control-panel button {
            padding: 10px 20px;
            font-size: 16px;
            margin: 5px;
            cursor: pointer;
            background: linear-gradient(135deg, #00b894, #00d26a);
            color: white;
            border: none;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        #control-panel button:hover {
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
        }
        #record {
            margin-top: 20px;
            width: 300px;
            height: 100px;
            overflow-y: scroll;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>
    <h1>九宫格抽奖</h1>
    <div class="grid" id="grid">
        <div class="cell">1</div>
        <div class="cell">2</div>
        <div class="cell">3</div>
        <div class="cell">4</div>
        <div class="cell">5</div>
        <div class="cell">6</div>
        <div class="cell">7</div>
        <div class="cell">8</div>
        <div class="cell">9</div>
    </div>
    <div id="control-panel">
        <button id="start">开始抽奖</button>
        <button id="stop" disabled>暂停抽奖</button>
    </div>
    <div>
        <h2>抽奖记录</h2>
        <div id="record"></div>
    </div>

    <script>
        const grid = document.getElementById('grid');
        const startButton = document.getElementById('start');
        const stopButton = document.getElementById('stop');
        const record = document.getElementById('record');
        const cells = document.querySelectorAll('.cell');
        let isRunning = false;
        let intervalId;

        function startLottery() {
            if (isRunning) return;
            isRunning = true;
            startButton.disabled = true;
            stopButton.disabled = false;

            intervalId = setInterval(() => {
                cells.forEach(cell => cell.classList.remove('active'));
                const randomIndex = Math.floor(Math.random() * cells.length);
                cells[randomIndex].classList.add('active');
            }, 100);
        }

        function stopLottery() {
            if (!isRunning) return;
            isRunning = false;
            startButton.disabled = false;
            stopButton.disabled = true;

            clearInterval(intervalId);
            const activeCell = document.querySelector('.active');
            if (activeCell) {
                const result = activeCell.textContent;
                const newRecord = document.createElement('p');
                newRecord.textContent = `抽中了：${result}`;
                record.appendChild(newRecord);
            }
        }

        startButton.addEventListener('click', startLottery);
        stopButton.addEventListener('click', stopLottery);
    </script>
</body>
</html>